<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Cookie;

class CookieMiddle
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {//判断登录过滤器

        // 执行动作
        if(Cookie::get('username')==null){
            //确定登陆后是否要跳转
            $backUrl = urlencode($request->fullUrl());
            return redirect("/admins/sys/loginfrom?back=".$backUrl);
        }
        return $next($request);
    }
}
